﻿@model trangbaocao.Models.FuelGeneratorAssociateModel

<script src="@Url.Content("~/Scripts/jquery.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery-ui.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery-ui-timepicker-addon.js")" type="text/javascript"></script>  
            
<div class="container_12">       
    <div class="grid_12">            
        <div class="module">
                @*<h2 align="right"><span align="right"><a href="@Url.Action("Fuel_For_GeneratorIndex", "Fuel")">Quay lại</a></span></h2>*@
                <h2 align="right"><span align="right"><a href="@Url.Action("FuelGeneratorUseList", "Fuel", new { device_stations_id = Model.device_stations_id, thang = Model.thang })">Quay lại</a></span></h2>                         
                    <div class="module-body">
                    @using (Html.BeginForm("EditFuelGeneratorUse", "Fuel", FormMethod.Post, new { id = "EditFuelGeneratorUse" }))
                    {                      
                        <div align="center">
                            <h3>CẬP NHẬT THÔNG TIN NHIÊN LIỆU CHO MÁY PHÁT ĐIỆN THÁNG @Model.thang NĂM @Model.nam</h3>
                            <div class="account" align="center"> 
                            <img src="@Url.Content("~/Content/Body/Images/Body_Images/Edit_Station.png")" width="12%" />
                            </div>
                        </div>
                        if (TempData["msg"] != null)
                        {                            
                            <span class="notification n-error">@TempData["msg"]</span>
                        } <p style="width:25%; float:left"></p>
                        
                        <table> 
                            <div style="width:63%; float:left">
                                <p align="center">
                                    <label style="width:55%; text-align:left;">Tên trạm: <b>@Html.DisplayFor(model => model.name)</b></label>                                                                      
                                </p> 
                                <p align="center">
                                    <label style="width:55%; text-align:left;">Địa chỉ: <b>@Html.DisplayFor(model => model.dia_chi)</b></label>                                                                      
                                </p>
                                <p align="center">
                                    <label style="width:55%; text-align:left;">Trung tâm: <b>@Html.DisplayFor(model => model.ten_trung_tam)</b></label>                                                                      
                                </p>
                                
                                <div class="select_date" align="center">
                                    <label style="width:55%; text-align:left;">Ngày sử dụng:</label>
                                    <p align="center" style="width:55%; text-align:left;">
                                        <input type="textbox" id="ngay_nhap" value="@Model.ngay_nhap" name="ngay_nhap" class="ngay_nhap" style="width:35%;">
                                    </p> @Html.ValidationMessageFor(model => model.ngay_nhap)                        
                                </div>
                                <div align="center">
                                    <label style="width:55%; text-align:left;">Số lít sử dụng:</label>
                                    <p align="center" style="width:55%; text-align:left">
                                         @Html.TextBoxFor(model => model.nhap_trong_thang, new { @id = "thoi_gian_hd", @name = "thoi_gian_hd", @class = "input-short", maxlength = 4 })
                                                                             
                                    <input type="checkbox" name="checkbox" @(Model.fuel_status == 1 ? "checked" : "") value="1"> <b style="color:Red">Dùng bảo dưỡng</b> 
                                </p>
                                <p style="width:55%; text-align:left">@Html.ValidationMessageFor(model => model.nhap_trong_thang)</p>
                                </div>
                                <div align="center">
                                    <label style="width:55%; text-align:left;">Ghi chú:</label>
                                    <p align="center" style="width:55%; text-align:left">
                                         @Html.TextBoxFor(model => model.ghi_chu, new { @name = "ghi_chu", @class = "input-custom", @style="width:60%" })
                                    </p>
                                </div>  
                                @Html.HiddenFor(model => model.id)      
                                @Html.HiddenFor(model => model.device_stations_id)  
                                @Html.HiddenFor(model => model.stations_id)
                                @Html.HiddenFor(model => model.main_stations_id)
                                @Html.HiddenFor(model => model.name)
                                @Html.HiddenFor(model => model.dia_chi)
                                @Html.HiddenFor(model => model.ten_trung_tam)
                                @Html.HiddenFor(model => model.nam)
                                @Html.HiddenFor(model => model.thang)  
                                     
                           </div>           
                      </table>                    
                        <div class="button" align="center">
                            <p style="width:40%; float:left"></p>
                            <p align="center" style="width:30%; text-align:left; margin-left:0px; float:left">
                                <input class="submit-green" type="button" onclick="form_submit();" value="Cập nhật" /> 
                                <input class="submit-gray" type="reset" value="Hủy" />
                                @*<input class="submit-gray" type="button"  onclick="location.href='@Url.Action("Index", "User")'" value="Quay lại" />*@
                            </p>
                        </div>  
                    }
                </div> <!-- End .module-body -->
            </div>  <!-- End .module -->
        <div style="clear:both;"></div>
    </div> <!-- End .grid_12 --> 
    <div style="clear:both;"></div>
</div> <!-- End .container_12 -->

<script type="text/javascript">
    //    @*$(document).ready(function () {
    //        $("#date").datepicker({ dateFormat: 'dd/mm/yy' });
    //    });*@
    $(document).ready(function () {
        $("#ngay_nhap").datepicker({ dateFormat: 'dd/mm/yy' });
    });
    function form_submit() {
        var thisDate = document.getElementById('ngay_nhap').value;
        var month = parseInt(thisDate.substr(3, 2));
        var thang = document.getElementById('thang').value;
        if (month == thang)
            document.forms["EditFuelGeneratorUse"].submit();
        else {
            var message = "Đang nhập liệu trong tháng " + thang + ". Phải chọn ngày trong tháng này!";
            alert(message);
        }
    }
</script>